@extends('layout.main')
@section('content')
    <form class="layui-form layui-form-pane" action="">
        @csrf
        <div class="layui-form-item">
            <label class="layui-form-label">服务器地址</label>
            <div class="layui-input-block">
                <input type="text" name="serve_url" value="{{ $serve_url }}" autocomplete="off" disabled class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">合作编码</label>
            <div class="layui-input-block">
                <input type="text" name="foot_puid" value="{{ empty($setting->foot_puid)?'':$setting->foot_puid }}" autocomplete="off" placeholder="请输入芯迈合作编码" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">appid</label>
            <div class="layui-input-block">
                <input type="text" name="wx_appid" value="{{ empty($setting->wx_appid)?'':$setting->wx_appid }}" autocomplete="off" placeholder="请输入公众号appid" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">appsecret</label>
            <div class="layui-input-block">
                <input type="password" lay-affix="eye" name="wx_appsecret" value="{{ empty($setting->wx_appsecret)?'':$setting->wx_appsecret }}" autocomplete="off" placeholder="请输入公众号appsecret" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">token</label>
            <div class="layui-input-block">
                <input type="text" name="wx_token" value="{{ empty($setting->wx_token)?'':$setting->wx_token }}" autocomplete="off" placeholder="请输入公众号令牌(Token)" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">sea_key</label>
            <div class="layui-input-block">
                <input type="text" name="wx_sea_key" value="{{ empty($setting->wx_sea_key)?'':$setting->wx_sea_key }}"  autocomplete="off" placeholder="请输入公众号消息加解密密钥(EncodingAESKey)" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item form-item-center">
            <button class="layui-btn" lay-submit lay-filter="report_setting">确认</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </form>
@endsection

@section('script')
    <script>

        // localStorage.setItem('token','tokentokentoken');

        layui.use(['form'], function(){
            var form = layui.form;
            var layer = layui.layer;
            // 提交事件
            form.on('submit(report_setting)', function(data){
                var loadIndex = layer.load(0);
                var $ = layui.$;
                var field = data.field; // 获取表单字段值

                axios.post('{{ route('setting') }}',field).then(ret => {
                    if(ret.status == 200){
                        layer.msg('保存成功', {icon: 1});
                    }else{
                        layer.msg(ret.message, {icon: 0});
                    }
                }).finally(() => {
                    layer.close(loadIndex)
                });

                return false; // 阻止默认 form 跳转
            });
        });
    </script>
@endsection
